package com.example.myfirstapp; import android.content.Context;

import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.content.ContentValues;

public class OperationHelper extends SQLiteOpenHelper {
	public static final String TABLE_OPERATION = "operations";
	public static final String COLUMN_ID = "_id";
	public static final String COLUMN_VALUE = "value";
	public static final String COLUMN_DATE = "date";
	public static final String COLUMN_CATEGORIE = "categorie";

	private static final String DATABASE_CREATE = "CREATE TABLE " +
		TABLE_OPERATION + "(" +
		COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
		COLUMN_VALUE + " INTEGER NOT NULL, " +
		COLUMN_DATE + " INTEGER NOT NULL," +
		COLUMN_CATEGORIE + "INTEGER NOT NULL);";

	public OperationHelper(Context context) {
		super(context, CategoriesHelper.DATABASE_NAME, null,
				CategoriesHelper.DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase database) {
		database.execSQL(DATABASE_CREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase database, int oldVersion,
			int newVersion) {
		database.execSQL("DROP TABLE IF EXISTS " + TABLE_OPERATION);
		onCreate(database);
	}
}
